package ae.pcfc.cldos.online.common.strategy.mail.sender.provider;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

import ae.pcfc.cldos.online.common.clddb.domain.AppMetaData;
import ae.pcfc.cldos.online.common.clddb.domain.MessageInbox;
import ae.pcfc.cldos.online.common.strategy.mail.sender.BaseEmailBuilder;
import ae.pcfc.cldos.online.common.strategy.mail.sender.IEmailSender;
import ae.pcfc.cldos.online.common.strategy.mail.sender.MailToUserSenderThread;
import ae.pcfc.cldos.online.gs.service.client.vo.NotificationVO;

/**
 * 
 * @author arosa
 *
 */
public class MainUserRejectMailStrategy extends BaseEmailBuilder implements IEmailSender {

	public void sendEmail(AppMetaData appMetaData, NotificationVO notificationVO) {
		notificationVO.setSubject(subject);
		notificationVO.setSubjectAr(subjectAr);
		Map<Object, Object> params =  notificationVO.getParameters();
		params.put("refNo", appMetaData.getClientRefNo());
		try{
			notificationVO.setMessage(
					ftlProcessorManager.processFtlTemplate(templateName, params));
			notificationVO.setMessageAr(
					ftlProcessorManager.processFtlTemplate(templateName+"_ar", params));
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		MessageInbox messageInboxNotification = new MessageInbox();
		messageInboxNotification.setMiMsgType(MessageInbox.MESSAGE_TYPE_NOTIFICATION);
		messageInboxNotification.setMiSentOn(new Date());
		messageInboxNotification.setMiActionFlag(MessageInbox.MESSAGE_ACTION_FLAG_NOT_DONE);
		messageInboxNotification.setMiDtls(notificationVO.getMessage());
		messageInboxNotification.setMiSubject(notificationVO.getSubject());
		//abed
		messageInboxNotification.setMiDtlsAr(notificationVO.getMessageAr());
		messageInboxNotification.setMiSubjectAr(notificationVO.getSubjectAr());
		messageInboxNotification.setAppId(appMetaData.getApplicationId());
		messageInboxDOM.add(messageInboxNotification);
		
		List<String> mailList = new ArrayList<String>();
		mailList.add(userDomainObjectManager.getUserEmailById(appMetaData.getUserId()));
		
		notificationVO.setEmailsList(mailList);
		MailToUserSenderThread mailToUserSenderThread = new MailToUserSenderThread(govtSysGS, notificationVO,fileStorageManager);
		mailToUserSenderThread.start();
		
	}

}
